<?php defined('BASEPATH') OR exit('No direct script access allowed');

// Code here is run before ALL controllers
class MY_Controller extends Controller
{
	// Deprecated: No longer used globally
	protected $data;

	public $module;
	public $controller;
	public $method;

	function MY_Controller()
	{
		parent::Controller();
		$this->benchmark->mark('my_controller_start');
		// Use this to define hooks with a nicer syntax
		$this->hooks =& $GLOBALS['EXT'];
		// Create a hook point with access to instance but before custom code
		$this->hooks->_call_hook('post_core_controller_constructor');

        // Work out module, controller and method and make them accessable throught the CI instance
        $this->module 				= $this->router->fetch_module();
        $this->controller			= $this->router->fetch_class();
        $this->method 				= $this->router->fetch_method();

		$langs = $this->config->item('supported_languages');

        $this->benchmark->mark('my_controller_end');
	}

	protected function is_ajax()
	{
		return $this->input->server('HTTP_X_REQUESTED_WITH') == 'XMLHttpRequest';
	}
}

/**
 * Returns the CI object.
 *
 * Example: ci()->db->get('table');
 *
 * @staticvar	object	$ci
 * @return		object
 */
function ci()
{
	return get_instance();
}